package com.itheima.controller;

import com.itheima.service.UserService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {

    //注入service
    //@Autowired    //本地注入

    /**Reference的作用
     * 1.从zookeeper注册中心获取userService的访问url
     * 2.进行远程调用RPC
     * 3.将结果封装为一个代理对对象，给变量赋值
     */
    @Reference  //远程注入
    private UserService userService;

    @RequestMapping(value = "/sayHello",produces = "text/html;charset=UTF-8")
    public String sayHello(String name){
        System.out.println(name);
        return userService.sayHello(name);
    }
}
